package com.cskaoyan.controller.extendController;

import com.cskaoyan.model.bean.Storage;
import com.cskaoyan.model.bean.advertise.Advertise;
import com.cskaoyan.model.bo.extend.ListBo;
import com.cskaoyan.model.vo.extend.BaseRespVo;
import com.cskaoyan.model.vo.extend.ListVo;
import com.cskaoyan.service.AdvertiseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author：Chunk
 * @Description:
 * @Date Created in 20:25 2021/4/8
 */
@RestController
@RequestMapping("admin")
public class AdvertiseController {

    @Autowired
    AdvertiseService advertiseService;

    @RequestMapping("ad/list")
    @RequiresPermissions("admin:ad:list")
    public BaseRespVo list(ListBo listBo){
        ListVo listVo = advertiseService.query(listBo);
        return BaseRespVo.ok(listVo);
    }

    @RequestMapping("ad/create")
    @RequiresPermissions("admin:ad:create")
    public BaseRespVo create(@RequestBody Advertise advertise){
        Advertise advertiseVo = advertiseService.adCreate(advertise);
        return BaseRespVo.ok(advertiseVo);
    }

    @RequestMapping("ad/update")
    @RequiresPermissions("admin:ad:update")
    public BaseRespVo update(@RequestBody Advertise advertise){
        Advertise advertiseVo = advertiseService.update(advertise);
        return BaseRespVo.ok(advertiseVo);
    }

    @RequestMapping("ad/delete")
    @RequiresPermissions("admin:ad:delete")
    public BaseRespVo delete(@RequestBody Advertise advertise){
        advertiseService.delete(advertise);
        return BaseRespVo.ok();
    }
//    @RequestMapping("storage/create")
//    public BaseRespVo storageCreate(MultipartFile file){
//        Storage storage = advertiseService.storageCreate(file);
//        return BaseRespVo.ok(storage);
//    }
}
